package obj.day6;

/**
 * @author げっしょく
 * @date 2021/7/22
 */
public class kuaipai {
    public static void main(String[] args) {
        int[] arr = {89 ,96 ,8 ,42 ,65 ,18 ,64,15};
        int left = 0;
        int right = arr.length - 1;
        prar(arr,left,right);
        for (int i = 0; i < arr.length; i++) {
            System.out.println(arr[i]);

        }
    }
 //89 ,96 ,8 ,42 ,65 ,18 ,64,15
    private static void prar(int[] arr , int left , int right) {
        if(left > right)
        {
            return ;
        }
        int left1 = left;
        int right1 = right;
        int about = arr[left];
        while(left1 < right1){
            while (arr[right1] >= about && right1 > left1) {
                right1--;

            }
            while (arr[left1] <= about && right1 > left1){
                left1 ++;
            }
            int tmp = arr[left1];
            arr[left1] = arr[right1];
            arr[right1] = tmp;
        }

        int tmp = arr[left1];
        arr[left1] = arr[left];
        arr[left] = tmp;
        prar(arr,left,left1 - 1);
        prar(arr,left1+1 , right);
    }
}
